//
//  SwiftCommonReference.swift
//  Screen
//
//  Created by Season02 on 10/20/16.
//  Copyright © 2016 alex.chih. All rights reserved.
//

//替代 oc 中的宏

import Foundation
import UIKit

class SRef: NSObject
{
    static let debug:Bool = false
    
    @objc
    enum EntityType:Int
    {
        case
        Video,
        Artic
    }
    
    @objc
    enum Color:Int
    {
        case
        mgcHomeRecycleImageIndicatorCurrentColor,
        mgcHomeRecycleImageIndicatorBackgroundColor,
        
        mgcNewsCommentHorizonLienBackgroundColor,
        mgcNewsCommentGuestFontColor,
        mgcNewsCommentConentFontColor,
        
        mgcActivationViewBackgroudColor,
        mgcActivationViewCommentFieldBorderColor,
        
        mgcGreen,
        mgcGreenDark,
        mgcGreenLight,
        
        interActionDigitGroundBackground,
        
        reactBackground,
        nothingBtn
    }
    
    @objc
    enum Length:Int
    {
        case
        screenWidth,
        mgcNewsDetailpicMinHeight,
        mgcNewsDetailpicMinWidth,
        mgcNewsListPicWidth,
        mgcNewsListPicHeight,
        
        mgcNewsCommentCellHeight,
        mgcNewsCommentCellImageHeight,
        
        mgcActivationViewButtonHeight,
        
        mgcInputViewSubmitButtonHeight,
        mgcInputViewSubmitButtonWidth,
        
        mgcInteractionViewHeight,
        mgcInteractionInputViewHeight,
        mgcInteractionInputViewTextViewHeight,
        
        newsDetailTitlePanelHeight,
        
        newsDetailSection,
        
        newsRecommandPicHeight,
        newsRecommandPicWidth
    }
    
    @objc
    enum Space:Int
    {
        case
        mgcNewsDetailTopSpace,
        mgcNewsDetailLeftSpace,
        mgcNewsDetailSmallSpace,
        mgcNewsDetailpicMinBottomSpace,
        mgcNewsDetailpicMinRightSpace,
        mgcNewsDetailRecommendTitleTopSpace,
        mgcNewsListPicTopSpace,
        mgcNewsListPicLeftSpace,
        mgcNewsListInforTopSpace,
        mgcNewsListPicRightSpace,
        mgcNewsListSubjectRightSpace,
        mgcNewsListTitleTopSpace,
        
        mgcNewsCommentCellGuestLabelTopSpace,
        mgcNewsCommentCellGuestLabelLeftSpace,
        mgcNewsCommentCellGuestWithContentGapSpace,
        mgcNewsCommentCellContentWithBottomLineGapSpace,
        
        mgcInputViewTopSpace,
        mgcInputViewLeftSpace,
        mgcInputViewBottomSpace,
        
        mgcInputViewSubmitButtonBottomSpace,
        
        newsDetailTitleLeft,
        newsDetailTitleBottom,
        
        newsRecommandLeft,
        newsRecommandTop,
        
        newsRecommandPicRight
    }
    
    @objc
    enum MGCURL:Int
    {
        case
        createComment,
        checkFavourited,
        addToFavourite,
        removeFromFavourite,
        
        requestToActive,
        unionAppPay,
        checkPayStatus,
        
        newsDetail,
        
        obtainComment,
        
        main
    }
    
    @objc
    enum theConst:Int
    {
        case
        serverUrl,
        wechat_key,
        wechat_secret,
        qq_key,
        weibo_key,
        weibo_redirect_uri,
        outer_login_url,
        store_id
    }
    
    @objc
    enum theApi:Int
    {
        case
        rise,
        check
    }
    
    @objc
    enum Text:Int
    {
        case
        mgcEntityNameArtic,
        mgcEntityNameVideo,
        
        entityAritc,
        entityVideo
    }
    
    @objc
    enum MGCKey:Int
    {
        case
        seEGOCacheNewsListEntityArray,
        seEGOCacheMediasListEntityArray,
        
        mgcMediaDetiaPage,
        mgcMediaDetiaPageRecommendList,
        mgcMediaDetiaPageTagList,
        
        mgcNewsDetailEntityGenericKey,
        mgcNewsDetailCommentGenericKey,
        mgcVideoDetailCommentGenericKey,
        
        mgcVideoDetiaPage,
        mgcVideoDetiaPageRecommendList,
        mgcVideoDetiaPageYouId,
        mgcVideoDetiaPageYouPass
    }
    
//    @objc
//    enum MGCTextSize:Int
//    {
//        case
//        proTextViewPlaceHolder,
//        nothingBtn,
//        
//        newsDetailTitle,
//        newsDetailDate,
//        
//        newsRecommandCellTitle,
//        newsRecommandCellInfor
//    }
    
//    @objc
//    static func MGCColor(_ color:Color) -> UIColor
//    {
//        switch color
//        {
//        case Color.mgcHomeRecycleImageIndicatorCurrentColor:
//            return MGCScreenCommon.getColor("9dc815")
//            
//        case Color.mgcHomeRecycleImageIndicatorBackgroundColor:
//            return MGCScreenCommon.getColor("4b4b4b")
//            
//        case Color.mgcNewsCommentHorizonLienBackgroundColor:
//            return MGCScreenCommon.getColor("e1e1e1")
//            
//        case Color.mgcNewsCommentGuestFontColor:
//            return MGCScreenCommon.getColor("434343")
//            
//        case Color.mgcNewsCommentConentFontColor:
//            return MGCScreenCommon.getColor("666666")
//            
//        case Color.mgcActivationViewBackgroudColor:
//            return MGCScreenCommon.getColor("eeeeee")
//            
//        case Color.mgcActivationViewCommentFieldBorderColor:
//            return MGCScreenCommon.getColor("c9c9c9")
//            
//        case Color.mgcGreen:
//            return MGCScreenCommon.getColor("9cc813")
//            
//        case Color.mgcGreenDark:
//            return MGCScreenCommon.getColor("85a818")
//            
//        case Color.mgcGreenLight:
//            return MGCScreenCommon.getColor("b3e419")
//            
//        case Color.interActionDigitGroundBackground:
//            return MGCScreenCommon.getColor("fc2258")
//            
//        case Color.reactBackground:
//            return MGCScreenCommon.getColor("ebebeb")
//            
//        case Color.nothingBtn:
//            return MGCScreenCommon.getColor("46b9ee")
//        }
//    }
    
//    @objc
//    static func MGCSpace(_ space:Space) -> CGFloat
//    {
//        switch space
//        {
//        case Space.mgcNewsDetailTopSpace:
//            return MGCScreenCommon.screenWidth() *   0.03
//            
//        case Space.mgcNewsDetailLeftSpace:
//            return MGCScreenCommon.screenWidth() *  0.038
//            
//        case Space.mgcNewsDetailSmallSpace:
//            return MGCScreenCommon.screenWidth() * 0.0134
//            
//        case Space.mgcNewsDetailpicMinBottomSpace:
//            return MGCScreenCommon.screenWidth() *  0.027
//            
//        case Space.mgcNewsDetailpicMinRightSpace:
//            return MGCScreenCommon.screenWidth() *   0.04
//            
//        case Space.mgcNewsDetailRecommendTitleTopSpace:
//            return MGCScreenCommon.screenWidth() *  0.028
//            
//        case Space.mgcNewsListPicTopSpace:
//            return MGCScreenCommon.screenWidth() *  0.028
//            
//        case Space.mgcNewsListPicLeftSpace:
//            return MGCScreenCommon.screenWidth() * 0.0387
//            
//        case Space.mgcNewsListInforTopSpace:
//            return MGCScreenCommon.screenWidth() *   0.02
//            
//        case Space.mgcNewsListPicRightSpace:
//            return MGCScreenCommon.screenWidth() *   0.03
//            
//        case Space.mgcNewsListSubjectRightSpace:
//            return MGCScreenCommon.screenWidth() *   0.03
//            
//        case Space.mgcNewsListTitleTopSpace:
//            return MGCScreenCommon.screenWidth() *  0.012
//            
//        case Space.mgcNewsCommentCellGuestLabelTopSpace:
//            return MGCScreenCommon.screenWidth() *  0.04
//            
//        case Space.mgcNewsCommentCellGuestLabelLeftSpace:
//            return MGCScreenCommon.screenWidth() *  0.04
//            
//        case Space.mgcNewsCommentCellGuestWithContentGapSpace:
//            return MGCScreenCommon.screenWidth() *  0.021
//            
//        case Space.mgcNewsCommentCellContentWithBottomLineGapSpace:
//            return MGCScreenCommon.screenWidth() *  0.02
//            
//            
//        case Space.mgcInputViewBottomSpace:
//            return MGCScreenCommon.screenWidth() * 0.1
//            
//        case Space.mgcInputViewLeftSpace:
//            return MGCScreenCommon.screenWidth() / 20
//            
//        case Space.mgcInputViewTopSpace:
//            return MGCScreenCommon.screenWidth() / 17
//            
//        case Space.mgcInputViewSubmitButtonBottomSpace:
//            return 8
//            
//        case Space.newsDetailTitleLeft:
//            return 12
//            
//        case Space.newsDetailTitleBottom:
//            return 8
//         
//        case Space.newsRecommandLeft:
//            return MGCScreenCommon.screenWidth() * 0.038
//            
//        case Space.newsRecommandTop:
//            return MGCScreenCommon.screenWidth() * 0.03
//            
//        case Space.newsRecommandPicRight:
//            return MGCScreenCommon.screenWidth() * 0.02
//        }
//    }
    
//    @objc
//    static func MGCLength(_ length:Length) -> CGFloat
//    {
//        switch length
//        {
//        case Length.mgcNewsDetailpicMinHeight:
//            return MGCScreenCommon.screenWidth() * 0.135
//            
//        case Length.mgcNewsDetailpicMinWidth:
//            return MGCScreenCommon.screenWidth() * 0.268
//            
//        case Length.mgcNewsListPicWidth:
//            return MGCScreenCommon.screenWidth() * 0.404
//            
//        case Length.mgcNewsListPicHeight:
//            return MGCScreenCommon.screenWidth() * 0.62
//            
//        case Length.mgcNewsCommentCellHeight:
//            return MGCScreenCommon.screenWidth() * 0.15
//            
//        case Length.mgcNewsCommentCellImageHeight:
//            return MGCScreenCommon.screenWidth() * 0.10
//            
//            
//        case Length.screenWidth:
//            return MGCScreenCommon.screenWidth()
//            
//        case Length.mgcActivationViewButtonHeight:
//            return 44
//            
//        case Length.mgcInputViewSubmitButtonHeight:
//            return MGCScreenCommon.screenWidth() / 14
//            
//        case Length.mgcInputViewSubmitButtonWidth:
//            return MGCScreenCommon.screenWidth() / 4.5
//            
//        case Length.mgcInteractionViewHeight:
//            return 44
//            
//        case Length.mgcInteractionInputViewHeight:
//            return 150
//            
//        case Length.mgcInteractionInputViewTextViewHeight:
//            return 85
//            
//        case Length.newsDetailTitlePanelHeight:
//            return MGCScreenCommon.screenWidth() * 0.195
//            
//        case Length.newsDetailSection:
//            return 15
//            
//        case Length.newsRecommandPicHeight:
//            return MGCScreenCommon.screenWidth() * 0.23
//            
//        case Length.newsRecommandPicWidth:
//            return MGCScreenCommon.screenWidth() * 0.39
//            
//            //            default:
//            //                return MGCScreenCommon.screenWidth() * 0
//        }
//    }
    
    @objc
    static func URL(_ url:MGCURL) -> String
    {
        let prefix = (SRef.debug) ? "https://apptest.media-plus.cn" : "https://app.media-plus.cn"
//        let prefix = "http://192.168.3.117:8080"
        
        var suffix:String? = nil
        
        switch url
        {
        case .createComment:
            suffix = "/mobile/main/comments/create"
            
            break
            
        case .checkFavourited:
            suffix = "/mobile/main/comments/checkNewscl"
            
            break
            
        case .addToFavourite:
            suffix = "/mobile/main/comments/addcl"
            
            break
            
        case .removeFromFavourite:
            suffix = "/mobile/main/comments/delcl"
            
            break
            
        case  .requestToActive:
            suffix = "/gmhy/mercyCode"
            
            break
            
        case .unionAppPay:
            suffix = "/gmhy/unionAppPay"
            
            break
            
        case .checkPayStatus:
            suffix = "/gmhy/appPayCheck"
            
            break
            
        case .newsDetail:
            suffix = "/mobile/main/article/sec/"
            
        case .main:
            return "http://app.media-plus.cn"
            
        default:
            return ""
        }
        
        return prefix + suffix!
    }
    
    @objc
    static func URL(_ url:MGCURL, type:EntityType, id:String) -> String
    {
        let prefix = (SRef.debug) ? "https://apptest.media-plus.cn" : "https://app.media-plus.cn"
//        let prefix = "http://192.168.3.117:8080"
        
        let suffix = type == .Artic ? MGCText(.entityAritc) : MGCText(.entityVideo)
        
        switch url {
        case .obtainComment:
            return prefix + "/mobile/main/comments/datalist/" + id + "?entityName=" + suffix;
        
        default:
            return ""
        }
    }
    
    @objc
    static func Const(const:theConst) -> String
    {
        switch(const){
        case .serverUrl:
//            return "http://192.168.3.160:9090/"
//            return "http://192.168.3.215:9090/"
//            return "http://localhost:9090/"
            return "https://app.media-plus.cn/"
            
        case .wechat_key:
            return "wx11f3e8dfbd1ecaad"
            
        case .wechat_secret:
            return "4e986250a0de7d73efe74d763d8984bf"
            
        case .qq_key:
            return "101412449"
            
        case .weibo_key:
            return "73826851"
            
        case .weibo_redirect_uri:
            return "https://api.weibo.com/oauth2/default.html"
            
        case .outer_login_url:
            return SRef.Const(const:.serverUrl) + "portal/user/outerLogin"
            
        case .store_id:
            return "1325419223"//444934666
        }
    }
    
    @objc
    static func Api(api:theApi) -> String
    {
        let prefix = SRef.Const(const: .serverUrl)
        
        switch api {
        case .rise:
            return prefix + "portal/unionPay/raise"
        case .check:
            return prefix + "portal/unionPay/check"
        }
    }
    
    @objc
    static func MGCText(_ text:Text) -> String
    {
        switch(text)
        {
        case Text.mgcEntityNameArtic:
            return "com.magicode.cms.entiy.base.Article"
            
        case Text.mgcEntityNameVideo:
            return "com.magicode.cms.entiy.base.Video"
            
        case Text.entityAritc:
            return "com.magicode.cms.entiy.base.Article"
            
        case Text.entityVideo:
            return "com.magicode.cms.entiy.base.Video"
        }
    }
    
    @objc
    static func Key(_ key:MGCKey, identiyier:String?) -> String
    {
        switch key
        {
        case MGCKey.seEGOCacheMediasListEntityArray:
            return "SeEGOCacheMediasListEntityArray"
            
        case MGCKey.seEGOCacheNewsListEntityArray:
            return "SeEGOCacheNewsListEntityArray"
            
        case MGCKey.mgcMediaDetiaPage:
            return "MGCMediaDetiaPage-" + identiyier!
            
        case MGCKey.mgcMediaDetiaPageRecommendList:
            return "MGCMediaDetiaPageRecommendList-" + identiyier!
            
        case MGCKey.mgcMediaDetiaPageTagList:
            return "MGCMediaDetiaPageTagList-" + identiyier!
            
        case MGCKey.mgcNewsDetailEntityGenericKey:
            return "mgcNewsDetailEntityGenericKey-" + identiyier!
            
        case MGCKey.mgcNewsDetailCommentGenericKey:
            return "mgcNewsDetailCommentGenericKey-" + identiyier!
            
        case MGCKey.mgcVideoDetailCommentGenericKey:
            return "mgcVideoDetailCommentGenericKey-" + identiyier!
            
        case MGCKey.mgcVideoDetiaPage:
            return "mgcVideoDetiaPage-" + identiyier!
            
        case MGCKey.mgcVideoDetiaPageRecommendList:
            return "mgcVideoDetiaPageRecommendList-" + identiyier!
            
        case MGCKey.mgcVideoDetiaPageYouId:
            return "mgcVideoDetiaPageYouId-" + identiyier!
            
        case MGCKey.mgcVideoDetiaPageYouPass:
            return "mgcVideoDetiaPageYouPass-" + identiyier!
        }
    }
    
//    @objc
//    static func TextSize(_ size:MGCTextSize) -> CGFloat
//    {
//        switch size
//        {
//        case .proTextViewPlaceHolder:
//            return 14
//            
//        case .nothingBtn:
//            return MGCScreenCommon.deviceSize() > DeviceSize.Screen4inch.rawValue ? 18 : 15
//            
//        case .newsDetailTitle:
//            return MGCScreenCommon.deviceSize() > DeviceSize.Screen4inch.rawValue ? 17 : 14
//            
//        case .newsDetailDate:
//            return MGCScreenCommon.deviceSize() > DeviceSize.Screen4inch.rawValue ? 14 : 11
//            
//        case .newsRecommandCellTitle:
//            return 12
//            
//        case .newsRecommandCellInfor:
//            return 11
//            
//        }
//    }
    
    @objc
    static func BeCGFloat(_ value:Int32) -> CGFloat
    {
        return CGFloat(Float(value))
    }
    
    
}
